import requests
from config import url, headers_web


class QuestionLibrary:
    def __init__(self):
        self.url = url
        self.headers = headers_web

    @classmethod
    def post_add_question(cls, url: str, params=None, json=None, headers=headers_web):
        """
        @Summary:新增题库题目
        @Description:1.云课堂老师端新增题库题目
        :param url:
        :param params:
        :param json:
        :return:
        """
        url = url + "/teachingApi/v1/questionlibrary/add"
        r = requests.post(url=url, headers=headers, params=params, json=json)
        return r

    @classmethod
    def post_del_question(cls, url: str, params=None, json=None, headers=headers_web, paramspath=None):
        """
        @Summary:删除题库题目
        @Description:1.云课堂老师端删除题库题目
        :param url:
        :param params:
        :param json:
        :param paramspath:
        :return:
        """
        url = url + f"/teachingApi/v1/questionlibrary/{paramspath}/del"
        r = requests.post(url=url, headers=headers, params=params, json=json)
        return r

    @classmethod
    def post_question_list(cls, url: str, params=None, json=None, headers=headers_web):
        """
        @Summary:获取题库题目
        @Description:1.云课堂老师端获取题库题目
        :param url:
        :param params:
        :param json:
        :return:
        """
        url = url + "/teachingApi/v1/questionlibrary"
        r = requests.post(url=url, headers=headers, params=params, json=json)
        return r

    @classmethod
    def post_question_random(cls, url: str, params=None, json=None, headers=headers_web):
        """
        @Summary:教师随机组卷
        @Description:1.云课堂教师端：创建测验随机组卷使用
        :param url:
        :param params:
        :param json:
        :return:
        """
        url = url + "/teachingApi/v1/teacher/random/testpaper"
        r = requests.post(url=url, headers=headers, params=params, json=json)
        return r
